package cn.gok.thread;

/**
 * @ClassName 线程优先级
 * @Description TODO
 * @Author HP
 * @Date 17:02 2022/7/12
 * @Version 1.0
 **/
public class 线程优先级 {
    public static void main(String[] args) {
        Thread t1 = new Thread(
                ()->{
                    int i =0;
                    while (true){
                        System.out.println("线程一的消息"+Thread.currentThread().getName());
                        if (i>100)
                        {
                            Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
                        }
                    }
                }
        );
        t1.setName("qaz");
        t1.setPriority(Thread.MAX_PRIORITY);
        t1.start();
        Thread t2 = new Thread(
                ()->{
                    while (true){
                        System.out.println("线程二的消息"+Thread.currentThread().getName());
                    }
                }
        );
        t2.setName("jsx");
        t2.setPriority(Thread.MIN_PRIORITY);
        t2.start();
    }


}
